<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <#include "/common/plateform/include/common-base.ftl">
    <title>日志字段设置</title>
</head>
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

    <!-- top start -->
    <#include "/common/plateform/top.ftl">
    <!-- top end -->

    <!-- left start -->
    <#include "/common/plateform/left-project.ftl">
    <!-- left end-->

    <!-- Main start -->
    <div class="content-wrapper">
        <style>
            .btn-checked-ico{
                background: url("${ctx}/images/plateform/ico_checkon.svg") no-repeat right bottom;
                background-size: auto auto;
                background-size: 21px 21px;
            }
        </style>
        <!-- Main start -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12 ibox">

                    <!--搜索  start -->
                    <div class="box box-info collapsed-box hidden">

                        <!--搜索title  end -->
                        <div class="box-body">
                            <form id="searchForm" class="form-horizontal" action="javascript:;">
                                <input type="hidden" name="pageName" value="log-model-detail-list"/>
                                <input type="hidden" name="formName" value="searchForm"/>
                                <input type="hidden" name="orderBy" value="metadata.data_attr"/>
                                <input type="hidden" name="metadata.w_sortId" value="${sortId}"/>
                            </form>

                        </div>
                    </div>
                    <!-- 搜索 end -->


                    <div class="box box-success">

                        <!--列表title  start -->
                        <div class="box-header with-border">
                            <h3 class="box-title">
                                <i class="fa fa-cog"
                                   onclick="javascript:void('-1')"></i> 日志监控字段设置[${objName}表]&nbsp;
                                <button onclick="toBack('${page_admin}/project/log-model-list');"
                                        class="btn btn-primary pull-right btn-xs" type="button"><i
                                        class="fa fa-reply"></i> 返回
                                </button>
                                <div class="lh25 pt10 f12 text-info">
                                    <i class="fa fa-info-circle"></i> 关键提示：点击下面字段后，就会自动进行操作日志的监控记录！
                                </div>
                            </h3>
                        </div>

                        <!-- /.box-header -->
                        <div class="box-body" id="dataList-body">

                        </div>

                    </div>
                </div>
            </div>




            <script type="text/template" id="dataList-template">
                <? for ( var i = 0; i < rows.length; i++) {?>
                    <div class ="col-lg-2 ">
                        <div class="box box-solid box-success text-center <?=rows[i].metadata.dataAttr?>_div" style="height: 50px; padding: 2px 5px; line-height: 20px;cursor: pointer"
                             onclick="toAdd(this,'<?=rows[i].metadata.dataAttr?>','<?=rows[i].metadata.dataFullName?>','<?=rows[i].metadata.dataRestrict?>')">
                            <input type="hidden" class="<?=rows[i].metadata.dataAttr?>_detailId"/>
                            <div class="auto-font-space"><?=rows[i].metadata.dataAttr?></div>
                            <div class="auto-font-space"><?=rows[i].metadata.dataFullName?></div>
                        </div>
                    </div>
                <?}?>
            </script>

            <script>
                var clickMenu = "log-model-list";
                var  dataListId, searchFormId;
                dataListId = "dataList";
                searchFormId = "searchForm";
                var totalCounts = 0;
                var defSysEname = strUtil.doNull(strUtil.getLocalStorage("sysEname"), "");
                $("#submitForm").find("input[name='sysName']").val(defSysEname);
                var modelId="${modelId}";
                $(function () {
                    //1、加载分页列表数据
                    getTableData();
                    //2、控制是否启用token
                    //setToken();
                });
                //加载列表数据
                function getTableData() {
                    var index_load = layer.load(1, {shade: false});
                        $.ajax({
                            type: 'get',
                            url: common_list_url,
                            data: $("#" + searchFormId).serialize(),
                            dataType: 'json',
                            async: false,
                            success: function (myData) {
                                console.log(myData);
                                totalCounts = myData.total;
                                var data = baidu.template(dataListId + "-template", eval(myData));
                                $("#" + dataListId + "-body").html(data);
                            }
                        });

                    $.ajax({
                            type: 'get',
                            url: common_list_url,
                            // data: {"modelId":modelId,"exeType":"modelDetailList","doCode":"logExecute"},
                            data:{"pageName":"log-model-detail-list","formName":"contrast","uctLogModelDetail.w_modelId":modelId},
                            dataType: 'json',
                            success: function (myData) {
                                // console.log("modelDetailList",myData);
                                var data = myData.rows;
                                for(var i = 0;i<myData.total;i++){
                                    var columnEname = data[i].uctLogModelDetail.columnEname;
                                    var detailId = data[i].uctLogModelDetail.detailId;
                                    // console.log(columnEname);
                                    // $("."+columnEname).attr("checked","checked");
                                    $("."+columnEname+"_div").addClass("btn-checked-ico box-info").removeClass("box-success");
                                    $("."+columnEname+"_detailId").html(detailId);
                                }
                                layer.close(index_load);
                            }
                        });
                }

                //打开添加页面
                function toAdd(obj ,dataAttr,dataFullName,dataRestrict) {
                    var index_load = layer.load(1, {shade: false});
                    var selecc = $(obj).hasClass("btn-checked-ico");
                    var data={};
                    if (!selecc) {
                        if(dataRestrict!="1"){
                            dataRestrict="0";
                        }
                       // data = {"modelId":modelId,"columnCname":dataFullName,"columnEname":dataAttr,"primaryKey":dataRestrict,"doCode":"logExecute","exeType":"saveModelDetail"};
                       data = {"uctLogModelDetail.modelId":modelId,"uctLogModelDetail.columnCname":dataFullName,"uctLogModelDetail.columnEname":dataAttr,"uctLogModelDetail.primaryKey":dataRestrict,"pageName":"log-model-detail-list","formName":"saveModelDetail"};
                    } else{
                        var detailId =$("."+dataAttr+"_detailId").text();
                        // data = {'detailId':detailId,exeType:"delModelDetail",doCode:'logExecute'};
                        data = {'uctLogModelDetail.w_detailId':detailId,"pageName":"log-model-detail-list","formName":"delModelDetail"};


                    }
                    $.ajax({
                        type:'post',
                        url:common_submit_url,
                        data:data,
                        dataType:'json',
                        success: function(myData){
                            console.log(myData);
                            if(myData.flag=="T"){
                                if (!selecc) {
                                    $("." + dataAttr + "_detailId").html(myData.msg);
                                    // layer.alert("添加日志监控字段成功");
                                    $(obj).addClass("btn-checked-ico box-info").removeClass("box-success");
                                }else{
                                    $(obj).addClass("box-success").removeClass("btn-checked-ico box-info");
                                }
                            }
                            layer.close(index_load);
                        }
                    });
                }
                function refresh() {
                    getTableData();
                }


                function setToken() {
                    $.ajax({
                        type: 'get',
                        url: ctx + '/sendPage/token?token=true',
                        dataType: 'text',
                        success: function (myData) {
                            // console.log(myData);
                            $('#formToken').val(myData);
                        }
                    });
                }

                function toBack(url) {
                    mytools.pjax(url);
                }

            </script>
        </section>
        <!-- Main end -->
    </div>
    <!-- /.content-wrapper -->
    <!-- foot start -->
    <#include "/common/plateform/top.ftl">
    <!-- foot start -->
</div>

</body>


</html>

